package com.pipayshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pipayshop.entity.Image;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author xiaoqiu
 * @date 2024/9/12 16:14
 * @description
 */
public interface ImageMapper extends BaseMapper<Image> {
    @Select("select origin_path from image where image_id = #{imageId}")
    String selectPath(@Param("imageId") String imageId);

    @Select("select image_id from image where origin_path = #{avatarImag}")
    String selectImageIdByPath(@Param("avatarImag") String avatarImag);

    void deleteBatchImageIds(@Param("imageIds")List<String> imageIds);

    List<String> selectPaths(@Param("imageIds") List<String> imageIds);
    @Update("UPDATE image SET del_flag =del_flag+1  WHERE md5 = #{md5}")
    int updateDelFlag(@Param("md5") String md5);

    @Select("select * from Image where del_flag=0")
    List<Image> getImagesByDelFlag();

    @Delete("delete from image where del_flag=0")
    boolean deleteImageByDelFlag();
}
